import java.io.File;
import java.io.FileInputStream;

/**

 * Created by asus on 2017/6/6.

 */
public class MTOD {
    /*

    public void Out(byte a[],char b[],int i){



            System.out.printf("%x",a[i]);

            System.out.print(" "+"\t");



            System.out.println("\n");



            System.out.print(b[i]+"\t"+" ");



        }

    */

    public static void main(String[] args) throws Exception {
        File file = new File(args[0]);
        byte arr1 []=new byte[(int)file.length()];
        char arr2 []=new char[(int)file.length()];

        FileInputStream fw = new FileInputStream(args[0]);
        FileInputStream fr = new FileInputStream(args[0]);
        for (int m=0;m<arr2.length;m++){
                    arr2[m]=(char)fr.read();
        }
                while (fw.read(arr1)!= -1){
                    int length = (int)file.length()/16; //行数

                    int wide = (int)file.length()%16;//余数

                   if (length==0){
                       length++;
                   }


                    for (int L =0;L<length;L++){
                       System.out.print("\n");
                        System.out.printf("%o",16*L);
                        System.out.print("\t");
                        for (int W=L*16;W<L*16+16;W++){
                            System.out.printf("%x",arr1[W]);
                            System.out.print(" "+"\t");
                        }
                        System.out.print("\n");
                        System.out.print(" "+"\t");
                        for (int w=L*16;w<L*16+16;w++){
                            System.out.print(arr2[w]+"\t"+" ");
                        }
                    }
                    if (wide!=0){
                        System.out.print("\n");
                        System.out.printf("%o",16*wide);
                        System.out.print("\t");
                        for (int n =0;n<wide;n++){
                            System.out.printf("%x",arr1[16*length+n]);
                            System.out.print(" "+"\t");
                        }
                        System.out.print("\n");
                        System.out.print(" "+"\t");
                        for (int j=0;j<wide;j++){
                            System.out.print(arr2[16*length+j]+"\t"+" ");
                        }
                        System.out.print("\n");
                        System.out.printf("%x",(int)file.length());
                    }










            /*

            if (file.length()%16==0){

                        for (int num =0;num<file.length()/16;num++){

                            for (int num1=0;num1<16;num1++){



                            }

                        }



                    }

                    */
                            /*

                    for (int i=0;i<arr1.length;i++){

                        System.out.printf("%x",arr1[i]);

                        System.out.print(" "+"\t");

                    }

                    System.out.println("\n");

                    for (int a=0;a<arr2.length;a++){

                        System.out.print(arr2[a]+"\t"+" ");



                    }

*/
                }
                fw.close();
    }
}
